<?php
class num{
	function FindNumbersWithSum($array, $sum) {
		$count = count($array);
		$arr = array();
		//判断
		if($count==null|| $count<2){
			return $array;
		}

		$index = 0;
		$end = $count-1;
		while($index < $end){
			if($array[$index]+$array[$end]==$sum){
				array_push($arr, $array[$index]);
				array_push($arr,$array[$end]);
				return $arr;
			}elseif($array[$index]+$array[$end] > $sum){
				$end--;
			}else $index++;
		}
		return $arr;
	}
}

$data = new num;
print_r($data->FindNumbersWithSum(array(1,2,3,4,5,6,7,12,15),7));

?>